package game.gameobject.misc;

import com.jme3.bullet.collision.shapes.BoxCollisionShape;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import game.DataStore;

public class Crate extends Geometry {
    protected float xExtent, yExtent, zExtent, mass;
    
    public Crate() {
	super("crate");

	initDefaultValues();
	createCrate();
    }

    private void initDefaultValues() {
	xExtent = 0.5f;
	yExtent = 0.5f;
	zExtent = 0.5f;
	mass = 10f;
    }

    private void createCrate() {
	createMesh();
	createMaterial();
    }

    private void createMesh() {
	setMesh(new Box(xExtent, yExtent, zExtent));
    }

    private void createMaterial() {
	material = new Material(DataStore.assetManager, "Common/MatDefs/Light/Lighting.j3md");
	material.setBoolean("UseMaterialColors",true);
	material.setColor("Diffuse",  ColorRGBA.White);
        material.setColor("Specular", ColorRGBA.White);
    }

    public void createPhysicsControl() {
	RigidBodyControl torchControl = new RigidBodyControl(new BoxCollisionShape(new Vector3f(xExtent, yExtent, zExtent)), mass);
        this.addControl(torchControl);
    }

    public float getMass() {
	return mass;
    }

    public float getxExtent() {
	return xExtent;
    }

    public float getyExtent() {
	return yExtent;
    }

    public float getzExtent() {
	return zExtent;
    }
}
